<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>添加分类</title>
    <link rel="stylesheet" th:href="@{/src/css/layui.css}">
</head>
<body>
<form class="layui-form" style="width: 80%;" id="auf">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" id="goodsTypeName" name="goodsTypeName" class="layui-input"
                   lay-verify="goodsTypeName" placeholder="请输入分类名称" >
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn  layui-btn-disabled"  shiro:lacksPermission="good:gt:save">立即提交</button>
            <button class="layui-btn" lay-submit="" lay-filter="addUser" shiro:hasPermission="good:gt:save">立即提交</button>
        </div>
    </div>
</form>
<script th:src="@{/src/layui.js}"></script>

<script>
        layui.use(['form','layer','laydate','jquery'],function () {
            var form = layui.form,
                $ = layui.jquery,
                layer = layui.layer;

            //添加
            form.on('submit(addUser)',function (data) {
                $.ajax({
                    url:'/goods/saveGoodType',
                    type:'post',
                    data:data.field,
                    dataType:'json',
                    success:function (res) {
                        if(res.code == 200){
                            layer.msg('添加成功',{icon:1},function () {
                                parent.layer.closeAll("iframe");
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(res.message,{icon:5});
                        }
                    }
                })
                return false; //表单不提交，通过ajax的方式异步提交数据。
            })
        })



</script>


</body>
</html>